/*
    使用loadable进行路由懒加载


*/
import loadable from '../utils/loadable'
import {Navigate} from 'react-router-dom'

// import Login from '../views/Login'
// import Home from '../views/Home'
// import ProductMgr from '../views/product/ProductMgr'
// import ProductCate from '../views/product/ProductCate'
// import ProductComment from '../views/product/ProductComment'
// import UserMgr from '../views/user/UserMgr'
// import UserLabel from '../views/user/UserLabel'
// import UserLevel from '../views/user/UserLevel'
// import Dashboard from '../views/operator/Dashboard'
const Login=loadable(()=>import('../views/Login'))
const Home=loadable(()=>import('../views/Home'))
const ProductMgr=loadable(()=>import('../views/product/ProductMgr'))
const ProductCate=loadable(()=>import('../views/product/ProductCate'))
const UserLabel=loadable(()=>import('../views/user/UserLabel'))
const UserLevel=loadable(()=>import('../views/user/UserLevel'))
const Dashboard=loadable(()=>import('../views/operator/Dashboard'))
const ProductComment=loadable(()=>import('../views/product/ProductComment'))
const UserMgr=loadable(()=>import('../views/user/UserMgr'))


//编写路由配置的数组
//下面的routes数组，将来会生成<Routes>
const routes=[
    //下面的每一个对象，将来生成<Route>对象
    {
        path:'/login',
        element:<Login/>
    },
    {
        path:'/',
        element:<Navigate to="home"/>
    },
    {
        path:'/home',
        element:<Home/>,
        children:[
            {
                index:true,
                element:<Navigate to="dashboard"/>
            },
            {
                path:'dashboard',
                element:<Dashboard/>   
            },
            {
                path:'productMgr',
                element:<ProductMgr/>
            },
            {
                path:'productCate',
                element:<ProductCate/>
            },
            {
                path:'productComment',
                element:<ProductComment/>
            },
            {
                path:'userMgr',
                element:<UserMgr/>
            },
            {
                path:'userLabel',
                element:<UserLabel/>
            },
            {
                path:'userLevel',
                element:<UserLevel/>
            }
        ]
    }
]
export default routes